package com.akuma.redmine.service.impl;

import com.akuma.common.util.JsonUtils;
import com.akuma.redmine.entity.ProjectsQuery;
import com.akuma.redmine.entity.UserQuery;
import com.akuma.redmine.entity.UsersQuery;
import com.akuma.redmine.exception.RedMineException;
import com.akuma.redmine.service.IUserService;
import com.akuma.redmine.util.RedMineHttpRequest;

import java.util.List;

/**
 * Created by akuma on 2016/10/13.
 *
 * @author akuma
 */
public class UserServiceImpl implements IUserService {

    public List<UserQuery> findAll() {
        String s = null;
        try {
            s = RedMineHttpRequest.adminGet("users.json");
        } catch (Exception e) {
            RedMineException.throwException(e);
        }
        System.out.println(s);
        UsersQuery usersQuery = JsonUtils.readValue(s, UsersQuery.class);
        if (usersQuery != null) {
            return usersQuery.getUsers();
        }
        return null;
    }
}
